package com.c611.smartclassroom.config;//package com.xgp.springboot.config;

import com.c611.smartclassroom.component.LogHandlerInterceptor;
import com.c611.smartclassroom.component.LoginHandlerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyApiConfig implements WebMvcConfigurer {


    @Bean
    public LogHandlerInterceptor logHandlerInterceptor() {
        return new LogHandlerInterceptor();
    }

    @Bean
    public LoginHandlerInterceptor loginHandlerInterceptor() {
        return new LoginHandlerInterceptor();
    }

//    暂时没有做拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /**
         * 注册登陆拦截器
         */
//        registry.addInterceptor(loginHandlerInterceptor())
//                .addPathPatterns("/**")
//                .excludePathPatterns("/login/**")
//                .excludePathPatterns("/phone/**")
//                .excludePathPatterns("/ali/**")
//                .excludePathPatterns("/page/login/login.html")
//                .excludePathPatterns("/css/**")
//                .excludePathPatterns("/images/**")
//                .excludePathPatterns("/js/**")
//                .excludePathPatterns("/json/**")
//                .excludePathPatterns("/layui/**")
//                .excludePathPatterns("/page/**")
//                .excludePathPatterns("/*.ico");

        /**
         * 注册日志拦截器
         */
//        registry.addInterceptor(logHandlerInterceptor())
//                .addPathPatterns("/classroom/**")   //拦截教室的控制器
//                .addPathPatterns("/workOrder/**")   //拦截工单的控制器
//                .addPathPatterns("/schedule/**")
//                .addPathPatterns("/zone/**")
//                .addPathPatterns("/sys/**")
//                .addPathPatterns("/build/**")
//                .addPathPatterns("/device/**")
//                .addPathPatterns("/school/**")
//                .addPathPatterns("/gateway/**")
//                .addPathPatterns("/user/**")
//                .excludePathPatterns("/*/get*")     //不拦截查询语句
//                .excludePathPatterns("/*/query*");

//                .addPathPatterns("/**").
//                excludePathPatterns("/login/**").
//                excludePathPatterns("/*/query*").
//                excludePathPatterns("/*/get*").
//                excludePathPatterns("/*.html").
//                excludePathPatterns("/css/**")
//                .excludePathPatterns("/images/**")
//                .excludePathPatterns("/js/**")
//                .excludePathPatterns("/json/**")
//                .excludePathPatterns("/layui/**")
//                .excludePathPatterns("/page/**")
//                .excludePathPatterns("/*.ico");
    }
}




